<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let list = [
      {class: 2, student: 'zs'},
      {class: 1, student: 'ls'},
      {class: 3, student: 'zs1'},
      {class: 6, student: 'zs2'},
      {class: 8, student: 'zs3'},
      {class: 5, student: 'zs4'},
      {class: 7, student: 'zs5'},
      {class: 4, student: 'zs6'}
    ]
    function fn (a,b) {
      return b.class - a.class
    }
    console.log(list.sort(fn))
  </script>
</body>
</html>